package com.ruoyi.web.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.web.domain.GuGupiao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.web.domain.GuTag;
import com.ruoyi.web.service.IGuTagService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 标签Controller
 * 
 * @author ruoyi
 * @date 2025-07-15
 */
@RestController
@RequestMapping("/tag")
public class GuTagController extends BaseController
{
    @Autowired
    private IGuTagService guTagService;

    /**
     * 查询标签列表
     */
    @RequiresPermissions("web:tag:list")
    @GetMapping("/list")
    public TableDataInfo list(GuTag guTag)
    {
        startPage();
        List<GuTag> list = guTagService.selectGuTagList(guTag);
        return getDataTable(list);
    }



    /**
     * 查询标签列表全部
     */
    @RequiresPermissions("web:tag:list")
    @GetMapping("/listAll")
    public TableDataInfo listAll(GuTag guTag)
    {
        List<GuTag> list = guTagService.selectGuTagListAll();
        return getDataTable(list);
    }

    /**
     * 导出标签列表
     */
    @RequiresPermissions("web:tag:export")
    @Log(title = "标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GuTag guTag)
    {
        List<GuTag> list = guTagService.selectGuTagList(guTag);
        ExcelUtil<GuTag> util = new ExcelUtil<GuTag>(GuTag.class);
        util.exportExcel(response, list, "标签数据");
    }

    /**
     * 获取标签详细信息
     */
    @RequiresPermissions("web:tag:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(guTagService.selectGuTagById(id));
    }

    /**
     * 新增标签
     */
    @RequiresPermissions("web:tag:add")
    @Log(title = "标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GuTag guTag)
    {
        return toAjax(guTagService.insertGuTag(guTag));
    }

    /**
     * 修改标签
     */
    @RequiresPermissions("web:tag:edit")
    @Log(title = "标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GuTag guTag)
    {
        return toAjax(guTagService.updateGuTag(guTag));
    }

    /**
     * 删除标签
     */
    @RequiresPermissions("web:tag:remove")
    @Log(title = "标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(guTagService.deleteGuTagByIds(ids));
    }




}
